var _excluded = ['children', 'fallbackRender'];
function _extends() {
  _extends = Object.assign
    ? Object.assign.bind()
    : function (target) {
        for (var i = 1; i < arguments.length; i++) {
          var source = arguments[i];
          for (var key in source) {
            if (Object.prototype.hasOwnProperty.call(source, key)) {
              target[key] = source[key];
            }
          }
        }
        return target;
      };
  return _extends.apply(this, arguments);
}
function _objectWithoutProperties(source, excluded) {
  if (source == null) return {};
  var target = _objectWithoutPropertiesLoose(source, excluded);
  var key, i;
  if (Object.getOwnPropertySymbols) {
    var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
    for (i = 0; i < sourceSymbolKeys.length; i++) {
      key = sourceSymbolKeys[i];
      if (excluded.indexOf(key) >= 0) continue;
      if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
      target[key] = source[key];
    }
  }
  return target;
}
function _objectWithoutPropertiesLoose(source, excluded) {
  if (source == null) return {};
  var target = {};
  var sourceKeys = Object.keys(source);
  var key, i;
  for (i = 0; i < sourceKeys.length; i++) {
    key = sourceKeys[i];
    if (excluded.indexOf(key) >= 0) continue;
    target[key] = source[key];
  }
  return target;
}
import { CloseCircleOutlined } from '@ant-design/icons';
import { Typography } from 'antd';
import 'antd/es/typography/style/index';
import React from 'react';
import { ErrorBoundary, useErrorBoundary } from 'react-error-boundary';
import Result from '../Result';
var Paragraph = Typography.Paragraph;
export { useErrorBoundary };

/**
 * 页面级错误捕获组件，防止白屏
 */
export default function CuErrorBoundary(_ref) {
  var children = _ref.children,
    fallbackRender = _ref.fallbackRender,
    rest = _objectWithoutProperties(_ref, _excluded);
  return (
    /*#__PURE__*/
    // @ts-ignore
    React.createElement(
      ErrorBoundary,
      _extends({}, rest, {
        fallbackRender: fallbackRender
          ? fallbackRender
          : function (_ref2) {
              var error = _ref2.error;
              return /*#__PURE__*/ React.createElement(
                Result,
                {
                  code: '500',
                  subTitle:
                    '\u51FA\u9519\u4E86\uFF0C\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458\u6216\u7A0D\u540E\u91CD\u8BD5\uFF01',
                  style: {
                    backgroundColor: '#fff',
                  },
                  asPage: true,
                },
                /*#__PURE__*/ React.createElement(
                  Paragraph,
                  {
                    style: {
                      whiteSpace: 'pre-wrap',
                    },
                  },
                  /*#__PURE__*/ React.createElement(CloseCircleOutlined, {
                    style: {
                      color: 'red',
                      marginRight: 10,
                    },
                  }),
                  error === null || error === void 0 ? void 0 : error.stack,
                ),
              );
            },
      }),
      children,
    )
  );
}
